package com.jt.www.admin.pay.service;

import com.jt.www.model.issue.RepushQo;
import com.jt.www.model.issue.entity.IssuePolicyLogEntity;
import com.jt.www.model.issue.entity.IssueRecordEntity;
import com.jt.www.model.issue.entity.MqMessageEntity;
import com.jt.www.model.pay.StatusRecordVO;
import com.jt.www.model.pay.vo.PayCertVO;
import com.jt.www.model.reps.ResultDTO;
import org.dom4j.Document;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Service;

import java.text.ParseException;
import java.util.List;

/**
 * @author admin_ltf
 * @create 2019-06-03 14:48
 */
@Service
public interface PayCertService {

    ResultDTO bindAndUpdateData(PayCertVO vo) throws Exception;


    ResultDTO updateApplicationStatus(List<StatusRecordVO> statusRecordVOs);

    /**
     * 报文重发
     *
     * @param repushQo
     * @return
     */
    ResultDTO updateMessageStatus(RepushQo repushQo);

    ResultDTO updateBackMessageStatus(RepushQo repushQo);

    /**
     * 根据投保单号获取电子保单or电子发票列表
     */
    List<IssuePolicyLogEntity> getPolicyOrInvoice(String appCode, String type);

    IssueRecordEntity getIssueRecord(String appCode);

    /**
     * 根据投保单号删除电子保单或者电子发票
     * 后续重新获取
     *
     * @param appCode
     * @return
     */
    int deletePolicyOrInvoice(String appCode);

    /**
     * 根据投保单号删除出单相关mq记录表
     *
     * @param appCode
     * @return
     */
    int deleteIssuePolicyLog(String appCode);


    /**
     * 根据投保单号获取到最大的消息队列
     *
     * @param appCode
     * @return
     */
    MqMessageEntity getMqMessage(String appCode);

    /**
     * 根据投保单号获取到mqId
     *
     * @param appCode
     * @return
     */
    String mqMessageEntity(String appCode);


    /**
     * 获取电子保单
     *
     * @param repushQo
     * @return
     */
    ResultDTO getPolicy(RepushQo repushQo) throws Exception;

    /**
     * 获取电子发票
     *
     * @param RepushQo
     * @return
     */
    ResultDTO getInvoice(RepushQo RepushQo) throws Exception;


    /**
     * 根据投保单号选择不同的红冲接口
     *
     * @param responseEntity
     * @param appCode
     * @param seqNo
     * @param doc
     * @return
     * @throws Exception
     */
    ResponseEntity<String> byAppCodeChoiceInterface(ResponseEntity<String> responseEntity, String appCode, String seqNo, Document doc) throws Exception;

    /**
     * 是否满足红冲
     *
     * @param issuePolicyLogEntity
     * @return
     */
    Boolean isRedRush(IssuePolicyLogEntity issuePolicyLogEntity);

    /**
     * 时间范围内是否允许第二次发送
     *
     * @param issuePolicyLogEntity
     * @return
     * @throws ParseException
     */
    Boolean isDateRedRush(IssuePolicyLogEntity issuePolicyLogEntity) throws ParseException;

    /*
     *  发票红冲
     * @Author xq.wu
     * @Date 16:00 2020/1/8
     * @Param [repushQo]
     * @return com.jt.www.model.reps.ResultDTO
     **/
    ResultDTO redRushInvoice(RepushQo repushQo, String make) throws Exception;
}
